package com.jbm.jbmsupplier.activity.loadhomepage.orderadapter

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.jbm.jbmsupplier.R
import com.jbm.jbmsupplier.R.id.stuti
import com.jbm.onehome.iface.IorderEntity
import java.util.*

/**
 * Created by 家帮忙 on 2017/9/20.
 */
class ManageAdapterOrder : BaseAdapter{


    override fun getItem(position: Int): Any {
return arraylist?.get(position)!!
    }

    override fun getItemId(position: Int): Long {
return  0
    }

    override fun getCount(): Int {
return arraylist?.size!!
    }

    private var context:Context?=null
    private var  arraylist: ArrayList<IorderEntity>?=null
private  var loadorder:LoadOrderData?=null
    constructor(context: Context?, arraylist: ArrayList<IorderEntity>?) : super() {
        this.context = context
        this.arraylist = arraylist
        loadorder= LoadOrderData()
    }
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var myviewhoder:MyViewHoder?=null
        var convertViews = convertView
        if (convertViews==null){
            convertViews=View.inflate(context,R.layout.lz_orderall,null)
            myviewhoder=MyViewHoder(convertViews!!)
            convertViews.setTag(myviewhoder)
           }else{
           myviewhoder=  convertViews!!.getTag()as MyViewHoder
           }
        myviewhoder?.order_image.visibility=View.GONE
        myviewhoder?.relativelayot.visibility=View.VISIBLE
        loadorder?.set(myviewhoder,position,arraylist!!.get(position))
        return convertViews!!

    }



    fun getDataNotify(arraylist: ArrayList<IorderEntity>?){
    this.arraylist=arraylist
      notifyDataSetChanged()
    }

  fun getPosition():ArrayList<IorderEntity>{
//更新数据

      return arraylist!!


  }

     inner  class MyViewHoder (view:View){
         var orderbianhao: TextView
        internal var orderzhuangtai:TextView
        internal var orderdate:TextView
        internal var orderfunr:TextView
        internal var orderdianhau:TextView
        internal var orderdizhi:TextView
        internal var ordername:TextView
        internal var gdbianhao:TextView
         internal var textview_title:TextView
         internal var textview_leixing:TextView
         internal var relativelayot: RelativeLayout
         internal  var order_image:ImageView
init{

    orderbianhao = view.findViewById(R.id.ddbh) as TextView
    orderzhuangtai = view.findViewById(stuti) as TextView
    orderdate = view.findViewById(R.id.ddshij) as TextView
    orderfunr = view.findViewById(R.id.funr) as TextView
    orderdianhau = view.findViewById(R.id.dianhua) as TextView
    orderdizhi = view.findViewById(R.id.dizhi) as TextView
    ordername = view.findViewById(R.id.tname) as TextView
    gdbianhao = view.findViewById(R.id.gdbianhao) as TextView
    textview_title = view.findViewById(R.id.textview_title) as TextView
    textview_leixing = view.findViewById(R.id.textview_leixing) as TextView
    relativelayot = view.findViewById(R.id.relativelayot) as RelativeLayout
    order_image = view.findViewById(R.id.order_image) as ImageView


}




    }


}